package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ShopController
 * Package: com.sky.controller.admin
 * Description:
 *
 * @Author JJQ
 * @create 2024/3/31 0031 23:13
 * @Version 1.0
 */
@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Api("店铺接口")
public class ShopController {
    private final RedisTemplate redisTemplate;
    public ShopController(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Integer status) {
        redisTemplate.opsForValue().set("SHOP_STATUS", status);
        return Result.success();
    }

    @GetMapping
    public Result<Integer> getStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
       return Result.success(status);
    }
}
